﻿

//<!--arguement-->
(function ($) {

    //window object
    console.log('(function ($))(): ');
    console.log(this);

    $.fn.movePlugin = function (options) {

        var settings = $.extend({
            'location': 'top',
            'grap': true
        }, options);

        // this jquery object
        console.log('$.fn: ');
        console.log(this);

        return this.each(function () {
            //
            console.log('this.each: ');
            console.log(this);
        });
    }
})(jQuery);
$(document).movePlugin();

//<!--method-->
(function ($) {

    var methods = {
        init: function (options) {
            console.log('init method');
        },
        show: function () {
            console.log(arguments[0]);
        },
        hide: function () {
            console.log('hide method');

        },
        destory: function () {
            return this.each(function () {
                $(window).unbind('.divPlugin');
            });
        },
        excute: function(){
            arguments[0].apply(this);
        }
    };

    $.fn.methodPlugin = function (method) {
        if (methods[method]) {
            return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
        } else if (typeof method === 'object' || !method) {
            return methods.init.apply(this, arguments);
        } else {
            $.error('method: ' + method + 'does not exist');
        }
    };
})(jQuery);

$(document).methodPlugin();
$(document).methodPlugin('hide');
$(document).methodPlugin('show', 'test show method');
$(document).methodPlugin('excute', function () {
    console.log('num');
});